package utils;

import java.util.ArrayList;
import java.util.Set;

import org.junit.platform.commons.util.StringUtils;

import com.alibaba.fastjson.JSONObject;

public class PojoCompareUtil {

    public static void compareJSON(String orderId, String jsonPre, String jsonNew) {
        JSONObject oldObject = JSONObject.parseObject(jsonPre);
        JSONObject newObject = JSONObject.parseObject(jsonNew);
        if (oldObject == null || newObject == null) {
            return;
        }
        Set<String> keys = oldObject.keySet();
        for (String key : keys) {
            String oldValue = oldObject.getString(key);
            String newValue = newObject.getString(key);
            if ((StringUtils.isNotBlank(oldValue) && !oldValue.equals(newValue)) || (StringUtils.isBlank(oldValue)
                && StringUtils.isNotBlank(newValue))) {
                System.out.println(newValue);
                System.out.println(oldValue);
            }

        }
    }

}
